Skip to content

fix grpc endpoint parse when no dns scheme is provided#822

Merged
JoshVanL merged 4 commits intodapr:mainfrom
famarting:fix-grpc-endpoint-parse-no-dns
Mar 23, 2026
Merged

fix grpc endpoint parse when no dns scheme is provided#822
JoshVanL merged 4 commits intodapr:mainfrom
famarting:fix-grpc-endpoint-parse-no-dns

Conversation

@famarting
Copy link
Copy Markdown
Contributor

@famarting famarting commented Mar 23, 2026

Description

I ran into this issue the other day with the dapr API exposed in *.7f000001.nip.io:30443 (which is equivalent to *.127.0.0.1.nip.io btw)

Without this fix I got this

== APP - server == 2026/03/23 17:33:08 server listening on port 3001
== APP - client == dapr client initializing for: https://grpc-prj5.7f000001.nip.io:30443
== APP - client == API Token loaded from the environment variable
== APP - client == 2026/03/23 17:33:08 INFO: [core] original dial target is: "dns:grpc-prj5.7f000001.nip.io:30443"
== APP - client == 2026/03/23 17:33:08 INFO: [core] [Channel #1] Channel created for target "dns:grpc-prj5.7f000001.nip.io:30443"
== APP - client == 2026/03/23 17:33:08 INFO: [core] [Channel #1] parsed dial target is: resolver.Target{URL:url.URL{Scheme:"dns", Opaque:"grpc-prj5.7f000001.nip.io:30443", User:(*url.Userinfo)(nil), Host:"", Path:"", Fragment:"", RawQuery:"", RawPath:"", RawFragment:"", ForceQuery:false, OmitHost:false}}
== APP - client == 2026/03/23 17:33:08 INFO: [core] [Channel #1] Channel authority set to "grpc-prj5.7f000001.nip.io:30443"
== APP - client == 2026/03/23 17:33:08 INFO: [core] [Channel #1] Channel Connectivity change to CONNECTING
== APP - client == 2026/03/23 17:33:08 INFO: [core] [Channel #1] Channel exiting idle mode
== APP - client == 2026/03/23 17:33:13 INFO: [core] [Channel #1] Channel Connectivity change to SHUTDOWN
== APP - client == 2026/03/23 17:33:13 INFO: [core] [Channel #1] Closing the name resolver
== APP - client == 2026/03/23 17:33:13 INFO: [core] [Channel #1] ccBalancerWrapper: closing
== APP - client == 2026/03/23 17:33:13 INFO: [core] [Channel #1] Channel deleted
== APP - client == 2026/03/23 17:33:13 failed to create Dapr client: error creating "DAPR_GRPC_ENDPOINT" client: error creating connection to 'https://grpc-prj5.7f000001.nip.io:30443': context deadline exceeded
== APP - client == exit status 1

With the fix I got this

== APP - server == 2026/03/23 17:34:38 server listening on port 3001
== APP - client == dapr client initializing for: https://grpc-prj5.7f000001.nip.io:30443
== APP - client == API Token loaded from the environment variable
== APP - client == 2026/03/23 17:34:39 INFO: [core] original dial target is: "grpc-prj5.7f000001.nip.io:30443"
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Channel created for target "grpc-prj5.7f000001.nip.io:30443"
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] parsed dial target is: resolver.Target{URL:url.URL{Scheme:"passthrough", Opaque:"", User:(*url.Userinfo)(nil), Host:"", Path:"/grpc-prj5.7f000001.nip.io:30443", Fragment:"", RawQuery:"", RawPath:"", RawFragment:"", ForceQuery:false, OmitHost:false}}
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Channel authority set to "grpc-prj5.7f000001.nip.io:30443"
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Channel Connectivity change to CONNECTING
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Resolver state updated: {
== APP - client ==   "Addresses": [
== APP - client ==     {
== APP - client ==       "Addr": "grpc-prj5.7f000001.nip.io:30443",
== APP - client ==       "ServerName": "",
== APP - client ==       "Attributes": null,
== APP - client ==       "BalancerAttributes": null,
== APP - client ==       "Metadata": null
== APP - client ==     }
== APP - client ==   ],
== APP - client ==   "Endpoints": [
== APP - client ==     {
== APP - client ==       "Addresses": [
== APP - client ==         {
== APP - client ==           "Addr": "grpc-prj5.7f000001.nip.io:30443",
== APP - client ==           "ServerName": "",
== APP - client ==           "Attributes": null,
== APP - client ==           "BalancerAttributes": null,
== APP - client ==           "Metadata": null
== APP - client ==         }
== APP - client ==       ],
== APP - client ==       "Attributes": null
== APP - client ==     }
== APP - client ==   ],
== APP - client ==   "ServiceConfig": null,
== APP - client ==   "Attributes": null
== APP - client == } (resolver returned new addresses)
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Channel switches to new LB policy "pick_first"
== APP - client == 2026/03/23 17:34:39 INFO: [pick-first-leaf-lb] [pick-first-leaf-lb 0xfb085614e10] Received new config {
== APP - client ==   "shuffleAddressList": false
== APP - client == }, resolver state {
== APP - client ==   "Addresses": [
== APP - client ==     {
== APP - client ==       "Addr": "grpc-prj5.7f000001.nip.io:30443",
== APP - client ==       "ServerName": "",
== APP - client ==       "Attributes": null,
== APP - client ==       "BalancerAttributes": null,
== APP - client ==       "Metadata": null
== APP - client ==     }
== APP - client ==   ],
== APP - client ==   "Endpoints": [
== APP - client ==     {
== APP - client ==       "Addresses": [
== APP - client ==         {
== APP - client ==           "Addr": "grpc-prj5.7f000001.nip.io:30443",
== APP - client ==           "ServerName": "",
== APP - client ==           "Attributes": null,
== APP - client ==           "BalancerAttributes": null,
== APP - client ==           "Metadata": null
== APP - client ==         }
== APP - client ==       ],
== APP - client ==       "Attributes": null
== APP - client ==     }
== APP - client ==   ],
== APP - client ==   "ServiceConfig": null,
== APP - client ==   "Attributes": null
== APP - client == }
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1 SubChannel #2] Subchannel created
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Channel exiting idle mode
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1 SubChannel #2] Subchannel Connectivity change to CONNECTING
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1 SubChannel #2] Subchannel picks a new address "grpc-prj5.7f000001.nip.io:30443" to connect
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1 SubChannel #2] Subchannel Connectivity change to READY
== APP - client == 2026/03/23 17:34:39 INFO: [pick-first-leaf-lb] [pick-first-leaf-lb 0xfb085614e10] SubConn 0xfb0855e08c0 reported connectivity state READY and the health listener is disabled. Transitioning SubConn to READY.
== APP - client == 2026/03/23 17:34:39 INFO: [core] [Channel #1] Channel Connectivity change to READY
== APP - client == 2026/03/23 17:34:39 client started, sending requests every 2 seconds...
== APP - server == 2026/03/23 17:34:41 [2026-03-23T17:34:41+01:00] GET /hello from [::1]:64356
== APP - client == 2026/03/23 17:34:41 [#1] GET /hello response: {"message":"Hello from the server!","timestamp":"2026-03-23T17:34:41+01:00"}
== APP - server == 2026/03/23 17:34:41 [2026-03-23T17:34:41+01:00] POST /echo from [::1]:64356
== APP - client == 2026/03/23 17:34:41 [#1] POST /echo response: {"echo":{"message":"echo request #1","request_number":1},"timestamp":"2026-03-23T17:34:41+01:00"}

FYI running my apps with the env vars GRPC_GO_LOG_VERBOSITY_LEVEL=99 GRPC_GO_LOG_SEVERITY_LEVEL=info to get these log outputs

Issue reference

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.69%. Comparing base (9571573) to head (828ed6b).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #822   +/-   ##
=======================================
  Coverage   54.69%   54.69%           
=======================================
  Files          51       51           
  Lines        3474     3474           
=======================================
  Hits         1900     1900           
  Misses       1434     1434           
  Partials      140      140           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes gRPC endpoint parsing so addresses that don’t explicitly specify a dns scheme are dialed as bare host:port targets (passthrough resolver), avoiding failures caused by gRPC target parsing/resolution behavior in the current dependency set.

Changes:

  • Track whether the original endpoint string omitted a scheme and, in that case, return host:port instead of dns:host:port.
  • Preserve existing dns: / dns://authority/... target formats when the caller explicitly selects the dns scheme.
  • Update parsing unit tests to reflect the new expected dial targets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
client/internal/parse.go Adjusts ParseGRPCEndpoint to return passthrough-style targets when no scheme is provided, while keeping explicit dns behavior.
client/internal/parse_test.go Updates expected targets in test cases to match the new parsing output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +152 to +156
// Use passthrough resolver (just host:port) instead of dns: scheme.
// gRPC v1.78's DNS resolver is broken with grpc.DialContext() — it
// never fires regardless of URI format. The passthrough resolver
// works correctly and grpc.DialContext() defaults to it for bare
// host:port targets.
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says gRPC v1.78 “DNS resolver is broken with grpc.DialContext() — it never fires regardless of URI format”, but this function still returns dns:... / dns://... targets when the caller explicitly uses the dns scheme. That makes the wording look broader than the actual behavior being worked around and could confuse future maintenance.

Consider rephrasing to the specific observed failure mode (e.g., dns:host:port being parsed as an opaque target / resolver not invoked for that form) and optionally link to an upstream gRPC issue or repo issue for context.

Suggested change
// Use passthrough resolver (just host:port) instead of dns: scheme.
// gRPC v1.78's DNS resolver is broken with grpc.DialContext() — it
// never fires regardless of URI format. The passthrough resolver
// works correctly and grpc.DialContext() defaults to it for bare
// host:port targets.
// Use passthrough resolver (just host:port) instead of the dns: scheme.
// In gRPC v1.78, targets of the form dns:host:port can be treated as
// opaque by grpc.DialContext(), so the DNS resolver is not invoked.
// Using a bare host:port target makes grpc.DialContext() fall back to
// the passthrough resolver, which resolves and connects correctly.

Copilot uses AI. Check for mistakes.
Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com>
Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com>
@JoshVanL JoshVanL merged commit be273ee into dapr:main Mar 23, 2026
22 checks passed
@famarting famarting deleted the fix-grpc-endpoint-parse-no-dns branch March 23, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants